package com.zhongke.cotrun.service.impl;

import com.zhongke.cotrun.mapper.ResearchMapper;
import com.zhongke.cotrun.model.pojo.Research;
import com.zhongke.cotrun.service.ResearchService;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 研究方向
 */
@Service
public class ResearchServiceImpl implements ResearchService {

    @Autowired
    ResearchMapper researchMapper;

    /**
     * 根据code返回查询结果
     * @param code//传来 的code
     * @param divider//分割符
     * @return
     */
    @Override
    public String selectResearch(String code, String divider) {

        //分割字符串成为数组
        String[] a = code.split(divider);

        //根据code值查看名字
        String [] m=  researchMapper.selectResearchName(a);


        //转成普通的字符串
        String n= StringUtils.join(m, divider);


        return n;
    }

    /**
     * 查询所有的研究方向
     * @return
     */
    @Override
    public List<Research> selectAllResearch() {

        return  researchMapper.selectAllResearch();
    }
}
